package inc.gome.dynamic.datasource.dynamic;

import com.google.auto.service.AutoService;
import com.google.common.collect.ImmutableSet;
import com.google.inject.Module;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.rest.internal.BaseHttpApiMetadata;

import java.net.URI;
import java.util.Properties;

@AutoService(ApiMetadata.class)
public class JenkinsApiMetadataCustomize extends
        /*定义JenkinsApiCustomize 代理 */
        BaseHttpApiMetadata<JenkinsApi> {

    public static final String API_VERSION = "1.0";
    public static final String BUILD_VERSION = "2.0";

    @Override
    public Builder toBuilder() {
        return new Builder().fromApiMetadata(this);
    }


    public JenkinsApiMetadataCustomize() {
        this(new Builder());
    }

    protected JenkinsApiMetadataCustomize(Builder builder) {
        super(builder);
    }

    public static Properties defaultProperties() {
        Properties properties = BaseHttpApiMetadata.defaultProperties();
        return properties;
    }

    public static class Builder extends
            BaseHttpApiMetadata.Builder<JenkinsApi, Builder> {

        protected Builder() {
           super(JenkinsApi.class);
           //链式调用
           id("jenkins").name("Jenkins API").
                   identityName("Optional Username").
                   credentialName("Optional Password")
                .defaultIdentity("").defaultCredential("")
                .documentation(URI.create("http://wiki.jenkins-ci.org/display/JENKINS/Remote+access+API"))
                .version(API_VERSION)
                   .buildVersion(BUILD_VERSION)
                   .defaultEndpoint("http://127.0.0.1:8080")
                .defaultProperties(JenkinsApiMetadataCustomize.defaultProperties());
        }

        @Override
        public JenkinsApiMetadataCustomize build() {
            return new JenkinsApiMetadataCustomize(this);
        }

        @Override
        protected Builder self() {
            return this;
        }

        @Override
        public Builder fromApiMetadata(ApiMetadata in) {
            return this;
        }
    }
}